<template>
<el-dialog title="" size='tiny' :visible.sync="dialogTableVisible" :modal-append-to-body="false" class="wrap" @close="cancel" :close-on-click-modal="false">
		 <div class="bt">升级</div>
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
		<el-form label-width="100px" class="form">
			<el-form-item label="班级名称">
				 <el-input v-model="vbjmc" icon="info" class="select-block"></el-input>
			</el-form-item>
			<el-form-item label="教材">
				<el-select v-model="vjcid" class="select-block" @change="getcomboxlist1">
						<el-option :label="v.mc" :value="v.id" v-for="v in comboxlist"></el-option>
        </el-select>
			</el-form-item>
			<el-form-item label="册">
				<el-select v-model="vcid" class="select-block" @change="getcomboxlist1">
						<el-option :label="v.mc" :value="v.id" v-for="v in comboxlist1"></el-option>
        </el-select>
			</el-form-item>
			<el-form-item label="老师名称">
				<el-select v-model="vlsid" class="select-block" @change="getcomboxlist2">
						<el-option :label="v.mc" :value="v.id" v-for="v in comboxlist2"></el-option>
        </el-select>
			</el-form-item>

		</el-form>
		<el-button type="info" class="submit" @click="submit">升级</el-button>

	</el-dialog>
</template>

<script type="text/javascript">
	import qs from 'qs'
	export default {
		props: ['params'],
		data() {
			return {
					vbjid :'',
					vjcid :'',
					vcid :'',
					vlsid :'',
					vbjmc:'',
					id:'',
				comboxlist: [],
				comboxlist1: [],
				comboxlist2: [],
				dialogTableVisible: true
			}
		},
		created() {
			this.id=this.params.id;
           this.getcomboxlist();
           this.getcomboxlist1();
           this.getcomboxlist2();
		},
		methods: {
			submit() {
//				alert(this.id);
				//检测
				this.$store.state.loading = true;
				//装载数据
				var logininfo = JSON.parse(localStorage.logininfo);
				var params2 = qs.stringify({
					bjid: this.id+'',
					lsid: this.vlsid+'',
					bjmc: this.vbjmc+'',
					cid: this.vcid+'',
					jcid: this.vjcid+''
				})
				//执行
				this.axios.post(this.$store.state.api + 'bj/sj', params2)
					.then(res => {

						if(res.data.code == 1) {
							this.$emit('close', { type: 'sj', cancel: false });
							this.$store.state.loading = false;
						} else {
//							alert(this.res.data.msg)
							this.$emit('close', { type: 'sj', cancel: false });
							this.$store.state.loading = false;
						}
					}).catch(res => {
						alert("服务器异常");
						this.$store.state.loading = false;
					})
			},
			cancel() {
				this.$emit('close', { type: 'sj', cancel: true })
			},
			getcomboxlist(){
        		var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				this.axios.get(this.$store.state.api + 'jc/chooselist', {
					params: {
						yhid: logininfo.id,
						xxid: logininfo.xxid
					}
				}).then(res => {
					let data = res.data.data;
					let list = data.list;
					this.comboxlist = list;
					console.log(this.comboxlist);
				}).catch(res => {
					this.searchLoading = false;
				})
        },
			getcomboxlist1() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				this.axios.get(this.$store.state.api + 'c/chooseclist', {
					params: {
						yhid: logininfo.id,
						xxid: logininfo.xxid,
						jcid: this.vjcid
					}
				}).then(res => {
					console.log(res)
					let data = res.data.data;
					let list = data.list;
					this.comboxlist1 = list;
					console.log(this.comboxlist1)
				}).catch(res => {
					console.log(res)
					this.searchLoading = false;
				})
			},
		getcomboxlist2() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				this.axios.get(this.$store.state.api + 'ls/getlslist', {
					params: {
						yhid: logininfo.id,
						xxid: logininfo.xxid
					}
				}).then(res => {
					let data = res.data.data;
					let list = data.list;
					this.comboxlist2 = list;
					console.log(this.comboxlist);
				}).catch(res => {
					this.searchLoading = false;
				})
			},


		}
	}
</script>

<style lang="less" scoped>
	.wrap {
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top: 0;
			left:0;
			background: #50BFFF;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}

		.input {
			width: 280px;
			display: inline-block;
			margin-left: 10px;
		}
		.input-block span {
			display: inline-block;
			width: 70px;
			text-align: right;
		}
		.close {
		    position: absolute;
		    top: 20px;
		    right: 20px;
		    color: #8492A6;
		    font-size: 16px;
		}
		.submit {
			width: 120px;
			display: block;
			margin: 0 auto;
			margin-top: 20px;
		}
		.wpfl{
			background: #fff;
			position: absolute;
			top: 5px;
			left: 5px;
		}
		.select-block{
			width: 85%;
		}
	}
</style>
